import request from "@/utils/request";

const _BASE_URL = "/biz/blueprint/node";

const BlueprintNodeAPI = {
  // 获取节点类别分页列表
  getCategoryPage(queryParams: BlueprintNodeCategoryQuery) {
    return request<any, BlueprintNodeCategoryVO[]>({
      url: `${_BASE_URL}/category/pages`,
      method: "get",
      params: queryParams,
    });
  },

  // 保存节点类别
  saveCategory(data: BlueprintNodeCategoryForm) {
    return request({
      url: `${_BASE_URL}/category/save`,
      method: "post",
      data: data,
    });
  },

  // 删除节点类别
  deleteCategoryByIds(ids: string) {
    return request({
      url: `${_BASE_URL}/category/${ids}`,
      method: "delete",
    });
  },

  // 获取节点分页列表
  getNodePage(queryParams: BlueprintNodePageQuery) {
    return request<any, PageResult<BlueprintNodeVO[]>>({
      url: `${_BASE_URL}/pages`,
      method: "get",
      params: queryParams,
    });
  },

  // 保存节点
  saveNode(data: any) {
    return request({
      url: `${_BASE_URL}/save`,
      method: "post",
      data: data,
    });
  },

  // 删除节点
  deleteNodeByIds(ids: string) {
    return request({
      url: `${_BASE_URL}/${ids}`,
      method: "delete",
    });
  },
  
  getCategories() {
    return request<any, any>({
      url: `${_BASE_URL}/categories`,
      method: "get",
    });
  },
  
};

export default BlueprintNodeAPI;

// 查询参数类型
export interface BlueprintNodeCategoryQuery  {
  keywords?: string;
}


// 查询参数类型
export interface BlueprintNodePageQuery extends PageQuery {
  keywords?: string;
  categoryId?: string;
}

// 节点类别VO
export interface BlueprintNodeCategoryVO {
  id: string;
  name: string;
  sort: number;
  createTime: Date;
  updateTime: Date;
  createUserId: string;
  updateUserId: string;
}

// 节点类别表单
export interface BlueprintNodeCategoryForm {
  id?: string;
  parentId?:string;
  name?: string;
  sort?: number;
}

// 节点VO
export interface BlueprintNodeVO {
  id: string;
  categoryId: string;
  label: string;
  type: string;
  icon: string;
  width: number;
  color: string;
  sort: number;
  data:string,
  description:string,
  createTime: Date;
  updateTime: Date;
  createUserId: string;
  updateUserId: string;
}

// 节点表单
export interface BlueprintNodeForm {
  id?: string;
  categoryId?: string;
  label?: string;
  type?: string;
  icon?: string;
  width?: number;
  color?: string;
  showHead?:string;
  sort?: number;
  description?: string;
  data?:any;
}